package com.zuo.seckilldemo.controller;

import com.zuo.seckilldemo.entity.User;
import com.zuo.seckilldemo.result.CodeMsg;
import com.zuo.seckilldemo.result.Result;
import com.zuo.seckilldemo.service.OrderService;
import com.zuo.seckilldemo.utils.UserThreadLocal;
import com.zuo.seckilldemo.vo.OrderDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zuogaocan
 * @since 2023-01-31
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @RequestMapping("/detail")
    @ResponseBody
    public Result detail(Long orderId){
        User user = UserThreadLocal.get();
        if (user==null)return Result.error(CodeMsg.SESSION_ERROR);
        OrderDetailVo order = orderService.detail(orderId);
        return Result.success(200,"成功",order);
    }
}
